import request from '@/utils/request'
import type { LifeEntityRelationship, NetworkVisualizationData } from './types'

// 网络关系API服务
export const networkApi = {
  // 获取网络可视化数据
  getVisualizationData(): Promise<NetworkVisualizationData> {
    return request.get('/network/visualization')
  },

  // 获取关系列表
  getRelationships(params?: {
    sourceEntityId?: string
    targetEntityId?: string
    relationshipType?: string
  }): Promise<LifeEntityRelationship[]> {
    return request.get('/relationships', { params })
  },

  // 创建关系
  createRelationship(data: Partial<LifeEntityRelationship>): Promise<LifeEntityRelationship> {
    return request.post('/relationships', data)
  },

  // 更新关系
  updateRelationship(id: string, data: Partial<LifeEntityRelationship>): Promise<LifeEntityRelationship> {
    return request.put(`/relationships/${id}`, data)
  },

  // 删除关系
  deleteRelationship(id: string): Promise<void> {
    return request.delete(`/relationships/${id}`)
  },

  // 获取网络健康状态
  getNetworkHealth(): Promise<any> {
    return request.get('/network/health')
  },

  // 获取强关系网络
  getStrongRelationshipNetwork(): Promise<NetworkVisualizationData> {
    return request.get('/network/visualization/strong-relationships')
  },

  // 根据类型获取网络可视化数据
  getNetworkVisualizationByType(type: string): Promise<NetworkVisualizationData> {
    return request.get(`/network/visualization/type/${type}`)
  }
}